/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gss;
import org.apache.commons.math.fraction.BigFraction;

import java.util.Vector;

/**
 *
 * @author mdm32
 */
public class Vertex {
    private BigFraction xcoord;
    private BigFraction ycoord;
    Vector<String> visibility;
    //private static final double EPSILON = 0.01;

    public Vertex(){
      visibility = new Vector<String>();
      //visibility.add("-1");
      xcoord = new BigFraction(-1);
      ycoord = new BigFraction(-1);
    }
    public Vertex(BigFraction x, BigFraction y){
        visibility = new Vector<String>();
        xcoord = x;
        ycoord = y;
    }
    public Vertex(Vector<String> vis, BigFraction x, BigFraction y){
        visibility = vis;
        xcoord = x;
        ycoord = y;
    }

    public BigFraction getX(){
        return xcoord;
    }
    public BigFraction getY(){
        return ycoord;
    }
    public Vector<String> getVisibility(){
        return visibility;
    }

    public void setX(BigFraction x){
        xcoord = x;
    }
    public void setY(BigFraction y){
        ycoord = y;
    }
    public void setVisibility(Vector<String> vis){
        visibility = vis;
    }

    public boolean equals(Vertex a){
        if((a.getX()).equals(xcoord) && (a.getY()).equals(ycoord))
            return true;
        else
            return false;
    }

    public void printVertex(){
        for(int i = 0; i < visibility.size(); i++){
            System.out.print(visibility.elementAt(i) + " ");
        }
        System.out.println("(" + xcoord + "," + ycoord + ")");
    }

    public void printVertex2(int numsegs){
        int a = numsegs-1;
        for(int i = 0; i < a; i++){
            if(visibility.contains("" + i))
                System.out.print(1 + " ");
            else
                System.out.print(0 + " ");
        }

        if(visibility.contains("" + a))
                System.out.print(1);
            else
                System.out.print(0);
        System.out.println();
    }

    public String asString1(){
        String vert = "" + xcoord.toString() + ", " + ycoord.toString();
        return vert;
    }

    public String asString2(int numsegs){
        String vert = "";
        int a = numsegs-1;
        for(int i = 0; i < a; i++){
            if(visibility.contains("" + i))
                vert = vert + "" + 1 + " ";
            else
                vert = vert + "" + 0 + " ";
        }

        if(visibility.contains("" + a))
                vert = vert + "" + 1;
            else
                vert = vert + "" + 0;
        return vert;
    }
}
